﻿using UnityEngine;
using System.Collections;
using PBMessage;
using UnityEngine.UI;
public class UILogin : BaseWidget
{

    public InputField DeviceId;
    public void OnClickLogin()
    {
        Game.Inst.Net.SetHandler(PBMesasgeID.SC_Login, (pkg) =>
         {
             SC_Login scLogin = ((SC_Login)pkg.Data);
             var selfPlayer = PlayerModel.Instance.Self;
             selfPlayer.GUID = scLogin.UserID;
             selfPlayer.Level = 1;
             selfPlayer.Rank = scLogin.Rank;
             selfPlayer.NickName = scLogin.NickName;
             UIManager.Inst.Show("UILobby");
             UIManager.Inst.Close(this);
         });
        Game.Inst.Net.Connect(() =>
        {
            CS_Login csLogin = new CS_Login();
            csLogin.DeviceId = DeviceId.text.Trim();
            Game.Inst.Net.NetClient.Send(PBMesasgeID.CS_Login, csLogin);
        });
    }
}
